package com.qingzhuge.entity;

import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import java.util.Date;

/**
 * @author : zero.xiao
 * @description : 指定id类型Long，并声明部分通用属性
 * @date :2018/6/7 0007 上午 9:34
 * @modified :
 */
@Getter
@Setter
@MappedSuperclass
public abstract class BaseModel extends BasePkLongEntity implements FindObjUserCreateBy,FindFindObjUpdateBy {
    private static final long serialVersionUID = -59228152343567012L;
    /**逻辑删除状态*/
    public static final String DEL_STATUS = "-1";
    /**正常状态*/
    public static final String DEL_STATUS_NORMEL = "0";
    /**逻辑删除字段*/
    public static final String FIELD_DELETED = "deleted";
    public static final String FIELD_DELETED_ = "deleted = ";
    public static final String FIELD_STATUS = "status";

    @ApiModelProperty("逻辑删除:删除-1,正常-0")
    @JSONField(serialize = false)
    private Integer deleted = 0;

    @ApiModelProperty("业务状态")
    private Integer status;

    @ApiModelProperty("明细，详情，描述")
    @Column(columnDefinition = "text")
    private String description;

    @ApiModelProperty("创建者")
    @Column(updatable = false)
    private Long createBy;

    @ApiModelProperty("修改者")
    @Column(insertable = false)
    private Long updateBy;

    @ApiModelProperty("修改时间")
    @Column(insertable = false)
    @LastModifiedDate
    private Date updateTime;


    public BaseModel() {
        super();
    }

    public BaseModel(String name) {
        super(name);
    }

    public BaseModel(Long id) {
        super(id);
    }

    public BaseModel(String name, Long id) {
        super(name, id);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    }

}
